package LeetCode;

import java.util.ArrayList;

import javax.swing.tree.TreeNode;

public class BinaryTreeInorderTraversal
{

  public static class TreeNode
  {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode(int x)
    {
      val = x;
    }
    
    public String toString(){
      return val+"";
    }
    
  }

  public ArrayList<Integer> inorderTraversal(TreeNode root)
  {
    // Start typing your Java solution below
    // DO NOT write main() function
    ArrayList<Integer> result = new ArrayList<Integer>();
    inorder(root, result);
    return result;
  }

  public void inorder(TreeNode root, ArrayList<Integer> result)
  {
    if (root == null) return;
    inorder(root.left, result);
    result.add(root.val);
    inorder(root.right, result);
  }

  /**
   * @param args
   */
  public static void main(String[] args)
  {
    // TODO Auto-generated method stub

  }

}
